subroutine time_advance
use var
implicit none

    integer i,m,j
    real(8) du,dv
    
    
    do j=1,gridsy
        do i=1,gridsx
            do m=1,4
                du=-(flux1(i,j,m)-flux1(i-1,j,m))/dx
                dv=-(flux2(i,j,m)-flux2(i,j-1,m))/dy
                if(KRK.eq.1)then
                    Qmean(i,j,m)=Qmean_n(i,j,m)+dt*du+dt*dv
                else if(KRK.eq.2)then
                    Qmean(i,j,m)=3.d0/4.d0*Qmean_n(i,j,m)+1.d0/4.d0*(Qmean(i,j,m)+dt*du+dt*dv)
                    !if( tstep==1 .and. krk==2 .and.m==2) then
                    !write(*,*)i,j,Qmean(i,j,2)!,Qmean(i,j,2),Qmean(i,j,4)
                    !endif
                else
                    Qmean(i,j,m)=1.d0/3.d0*Qmean_n(i,j,m)+2.d0/3.d0*(Qmean(i,j,m)+dt*du+dt*dv)
                end if
         end do
        enddo
         
    end do
    
    
    
    
    

end subroutine 